<script setup>
import { getListPatrolRecord } from '../../api/getList'
import { ref } from 'vue'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'

const usePartrolRecord = () => {
  const list = ref([])
  const totals = ref(0)

  const getListPatrolRecords = async (pageNum) => {
    const { rows, total } = await getListPatrolRecord({
      pageNum: pageNum ? pageNum : 1,
      pageSize: 20,
    })
    list.value = list.value.concat(rows)
    totals.value = total
  }

  return {
    list,
    totals,
    getListPatrolRecords,
  }
}

const { list, getListPatrolRecords, totals } = usePartrolRecord()

onReachBottom(() => {})

onLoad(() => {
  getListPatrolRecords()
})
</script>
<template>
  <view class="content">
    <song-lazyLoadList
      @loadMore="getListPatrolRecords"
      :total="totals"
      :pageNum="1"
      :pageSize="20">
      <song-item
        v-for="item in list"
        :title="item.name"
        :content="item.hash"></song-item>
    </song-lazyLoadList>
  </view>
</template>
